/* IFTRUE_ONLY_NANCHANG
import { statusEnergyConsumptionStructureSchedule2 } from '@/api/enterpriseQuarterlyReport2'
FITRUE_ONLY_NANCHANG */
/* IFTRUE_NOT_NANCHANG */
import { statusEnergyConsumptionStructureSchedule2 } from '@/api/enterpriseQuarterlyReport'
/* FITRUE_NOT_NANCHANG */
import { TABLE_RESOLVED, TABLE_REJECTED } from '@/config'

export default {
  methods: {
    async auditTable (status, reason = '') {
      try {
        await statusEnergyConsumptionStructureSchedule2({
          tenantId: this.selectEnterpriseId,
          tableIdList: this.myIds,
          reportStatus: status,
          year: this.year,
          quarter: this.quarter,
          illustrate: reason,
        })
        this.$message.success('操作成功')

        // 暂存、上报、通过、驳回后返回（刷新）
        this.back(true)
      } catch (e) {
        console.warn(e)
      }
    },
    resolve() {
      this.auditTable(TABLE_RESOLVED)
    },
    reject() {
      this.$prompt('退回理由：', '提示', {
        closeOnClickModal: false,
        inputPattern: /\S+/,
        inputType: 'textarea',
        inputPlaceholder: '请输入退回理由'
      }).then(({ value }) => {
        this.auditTable(TABLE_REJECTED, value)
      }).catch(() => { })
    },
  }
}
